//
//  IconPickerController.swift
//  ToDoList
//
//  Created by Qingke on 16/4/16.
//  Copyright © 2016年 Qingke. All rights reserved.
//

import UIKit

protocol iconPickerDelegate: class {
    func inconPickerViewController(viewcontroller: IconPickerController, iconDidFinishPick icon: String)
}

class IconPickerController: UITableViewController {

    let icons = ["No Icon","Appointments","Drinks","Birthdays","Chores","Folder","Groceries","Inbox","Photos","Trips"]
    weak var iconDelegate: iconPickerDelegate!
    override func viewDidLoad() {
        super.viewDidLoad()

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    // MARK: - Table view data source

 
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return icons.count
    }
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCellWithIdentifier("iconCell", forIndexPath: indexPath)
        let icon = icons[indexPath.row]
        cell.textLabel?.text = icon
        cell.imageView?.image = UIImage(named: icon)
        return cell
    }

    override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
        
        let icon = icons[indexPath.row]
        iconDelegate.inconPickerViewController(self, iconDidFinishPick: icon)
        navigationController?.popViewControllerAnimated(true)
    }
}
